<template>
  <div class="item-table-root mc-table">
    <el-table stripe height="277" border size="mini" :data="tableData" style="width: 100%">
      <template v-for="(headerOptions,index) in tableColumn">
        <el-table-column v-if="headerOptions.type=='slot'" :label="headerOptions.name" :width="headerOptions.width" align="center"
                         :prop="headerOptions.prop">
          <template slot-scope="scope">
            <div>
              <slot :name="headerOptions.prop" :row="scope.row"></slot>
            </div>
          </template>
        </el-table-column>
        <el-table-column v-else :label="headerOptions.name" :width="headerOptions.width" align="center"
                         :prop="headerOptions.prop">
          <template slot-scope="scope">
            <el-tooltip effect="light" :content="`${scope.row[headerOptions.prop]}`" placement="top">
              <div class="table-column">{{scope.row[headerOptions.prop]}}</div>
            </el-tooltip>
          </template>
        </el-table-column>
      </template>

    </el-table>
  </div>
</template>

<script>
  import { reactive, toRefs, onMounted, ref, watch, computed } from '@vue/composition-api'

  export default {
    name: 'itemTable',
    props: {
      tableData: {
        type: Array,
        default: () => {
          return []
        }
      },
      tableColumn: {
        type: Array,
        default: () => {
          return []
        }
      }
    },
    setup(props, content) {
      let data = reactive({})
      return { ...toRefs(data) }
    }
  }
</script>

<style scoped lang="scss">
  .item-table-root {
    .table-column {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }
</style>
